<script lang="ts" setup>
// import NavigationBar from "@/components/NavigationBar/index.vue";
import { useI18n } from "vue-i18n";
import { ref, onMounted } from "vue";
import { ActivityAxios } from "@/api";
import { UserStore } from "@/store";
import { showSuccessToast } from "vant";
const userStore = UserStore();
const { t } = useI18n();
const arrlist: any = ref([]);
const texts = ref([] as any);
onMounted(() => {
  getconfig();
  getconfigDesc();
  if (userStore.isLogin) {
    //获取救济金配置
    getReliefInfo();
  }
});
//救济金活动配置
const getconfig = () => {
  ActivityAxios.getconfig({ acttype: 2 }).then(res => {
    arrlist.value = res.configs;
  });
};

// 描述
const getconfigDesc = () => {
  ActivityAxios.getActConfigDesc({ actType: 2 }).then((res: any) => {
    texts.value = res.list;
  });
};

const reliefInfo: any = ref({
  todayExpected: 0,
  todayLose: 0,
  yesterdayExpected: 0,
  yesterdayLose: 0,
});
//获取救济金配置
const getReliefInfo = () => {
  ActivityAxios.getReliefInfo().then(res => {
    reliefInfo.value = res;
  });
};

//获取救济金
const clickReceiveRelief = () => {
  if (userStore.isLogin && reliefInfo.value.yesterdayExpected / 100 > 0) {
    ActivityAxios.getReceiveRelief().then(res => {
      if (res === null) {
        showSuccessToast("Success");
        getReliefInfo();
      }
    });
  }
};
</script>
<template>
  <!-- 救济金 -->
  <div class="frame-div">
    <!-- <NavigationBar :navigationName="t('navigationBar.relief')" /> -->
    <!-- <div class="interval-frame"></div> -->
    <div class="content-frame">
      <div class="card-frame">
        <div class="card-top-frame df ai-center jc-space-between">
          <div class="left-frame df ai-center">
            <img src="@/image/new_img/activity/zengbi_caise.png" />
            <div class="title-text">{{ t("activity.relief.currentLosses") }}</div>
          </div>
          <div class="money-frame df ai-center">
            <div class="moneyVal-type">{{ t("currencyType.pt") }}</div>
            <div class="moneyVal-frame">{{ reliefInfo.todayLose / 100 }}</div>
          </div>
        </div>
        <div class="bottom-content">
          <img class="content-img" src="@/image/new_img/activity/gift_card_line2.svg" />
          <div class="text-frame">
            <div class="text-title">{{ t("activity.relief.currentLossesTilte") }}</div>
            <div class="text-money df ai-center jc-center">
              {{ t("currencyType.pt") }}
              <text class="money-val">{{ reliefInfo.todayExpected / 100 }}</text>
            </div>
          </div>
        </div>
      </div>
      <div class="card-frame card-frame2">
        <div class="card-top-frame df ai-center jc-space-between">
          <div class="left-frame df ai-center">
            <img src="@/image/new_img/activity/zengbi_caise.png" />
            <div class="title-text textColor">{{ t("activity.relief.pastLoss") }}</div>
          </div>
          <div class="money-frame df ai-center">
            <div class="moneyVal-type textColor1">{{ t("currencyType.pt") }}</div>
            <div class="moneyVal-frame textColor1">{{ reliefInfo.yesterdayLose / 100 }}</div>
          </div>
        </div>
        <div class="bottom-content">
          <img
            class="content-img"
            style="z-index: -1"
            src="@/image/new_img/activity/gift_card_line2.svg"
          />
          <div class="text-frame">
            <div class="text-title text-title1">{{ t("activity.relief.pastLossTitle") }}</div>
            <div class="text-money df ai-center jc-center">
              {{ t("currencyType.pt")
              }}<text class="money-val">{{ reliefInfo.yesterdayExpected / 100 }}</text>
            </div>
          </div>
          <div
            class="claim-btn-disable"
            :class="{ 'add-claim-btn-disable': reliefInfo.yesterdayExpected / 100 > 0 }"
            @click="clickReceiveRelief"
          >
            {{ t("activity.relief.toReceive") }}
          </div>
        </div>
        <!-- 列表 -->
        <div class="list-frame">
          <div class="top-title-frame">
            <img class="content-img" src="@/image/new_img/activity/gift_card_line2.svg" />
            <div class="title-conten df ai-center">
              <img class="rescue-gold" src="@/image/new_img/activity/rescue_gold_m.svg" />
              <div>{{ t("activity.relief.reliefListName") }}</div>
            </div>
          </div>
          <div class="list-conten">
            <div class="list-title df">
              <div class="one-level list-title-name">{{ t("activity.relief.level") }}</div>
              <div class="tew-frame tew-frame1 list-title-name">
                {{ t("activity.relief.lossValue") }}
              </div>
              <div class="tew-frame list-title-name">{{ t("activity.relief.compensate") }}</div>
            </div>
            <div class="list-val-frame df fw-wrap">
              <div v-for="(item, index) in arrlist" :key="index" class="list-title df">
                <div
                  class="one-level list-title-name colortext"
                  :class="[(index + 1) % 2 != 0 ? 'single' : 'pair']"
                >
                  {{ item.ReliefConfig.Grade }}
                </div>
                <div
                  class="tew-frame tew-frame1 list-title-name colortext"
                  :class="[(index + 1) % 2 != 0 ? 'single' : 'pair']"
                >
                  {{ t("currencyType.pt") }}≥{{ item.ReliefConfig.GameLose / 100 }}
                </div>
                <div
                  class="tew-frame list-title-name colortext"
                  :class="[(index + 1) % 2 != 0 ? 'single' : 'pair']"
                >
                  {{ item.ReliefConfig.ReliefRate }}%
                </div>
              </div>
            </div>
          </div>
        </div>
        <!-- 分割线 -->
        <div class="divider-frame df ai-center jc-center">
          <div class="divider-div"></div>
          <div class="divider-name">{{ t("activity.eventDescription") }}</div>
          <div class="divider-div divider-div-rigth"></div>
        </div>
        <div class="eventDescription-frame">
          <div v-for="(items, index) in texts" :key="index" class="textWrap">
            {{ `${index + 1}.${items?.actDescContent}` }}
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<style lang="less" scoped>
.content-frame {
  width: calc(100% - 42px);
  height: auto;
  margin-left: 21px;
  background-color: #1b0a24;
  margin-top: 30px;
  padding-top: 10px;
  padding-bottom: 30px;

  .card-frame {
    width: 100%;
    height: auto;
  }

  .card-top-frame {
    width: 100%;
    height: 83px;
    border-radius: 20px 20px 0 0;
    background-image: linear-gradient(
      135deg,
      rgba(255, 255, 255, 0.25) 0%,
      rgba(255, 255, 255, 0.04) 100%
    );

    .left-frame {
      width: auto;
      height: auto;
      margin-left: 32px;

      img {
        width: 32px;
        height: 32px;
        opacity: 0.45;
      }

      .title-text {
        font-size: 27px;
        color: rgba(255, 255, 255, 0.25);
        margin-left: 10px;
      }
      .textColor {
        color: rgba(255, 255, 255, 0.65);
      }
    }

    .money-frame {
      width: auto;
      height: 45px;
      border-left: 1px solid rgba(255, 255, 255, 0.15);
      padding-left: 20px;
      margin-right: 32px;
    }

    .moneyVal-type {
      color: rgba(255, 255, 255, 0.25);
      font-size: 24px;
    }

    .moneyVal-frame {
      font-size: 34px;
      color: rgba(255, 255, 255, 0.25);
      margin-left: 10px;
    }
    .textColor1 {
      color: rgba(255, 255, 255, 0.85);
    }
  }

  .bottom-content {
    width: 100%;
    height: 161px;
    overflow: hidden;
    margin-top: 10px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 0 0 20px 20px;
    position: relative;
    top: 0;
    left: 0;
    z-index: 100;

    .content-img {
      width: 100%;
      height: 239px;
      opacity: 0.05;
      position: absolute;
      top: 0;
      left: 0;
      z-index: 10;
    }

    .text-frame {
      width: 100%;
      height: auto;
      margin-top: 28px;
      text-align: center;
    }

    .text-title {
      font-size: 28px;
      color: rgba(255, 255, 255, 0.45);
    }
    .text-title1 {
      color: rgba(255, 255, 255, 0.65);
    }
    .money-val {
      color: #ffffff;
      margin-left: 6px;
      font-size: 34px;
    }

    .text-money {
      font-size: 24px;
      color: rgba(255, 255, 255, 0.45);
      text-align: center;
      margin-top: 22px;
    }
  }
}

.card-frame2 {
  margin-top: 20px;

  .bottom-content {
    height: 258px;

    .content-img {
      height: 265px;
      left: -25px;
    }
  }

  .claim-btn-disable {
    width: 143px;
    height: 56px;
    border-radius: 14px;
    margin: auto;
    margin-top: 42px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    font-size: 24px;
    line-height: 56px;
    text-align: center;
    color: rgba(255, 255, 255, 0.25);
  }
  .add-claim-btn-disable {
    color: #000000;
    background-image: linear-gradient(to right, #f3c28a, #d78545);
  }
  .list-frame {
    width: 100%;
    height: auto;

    .top-title-frame {
      width: 100%;
      height: 109px;
      background: rgba(255, 255, 255, 0.04);
      border-radius: 10px;
      position: relative;
      left: 0;
      top: 0;
      margin-top: 45px;
      overflow: hidden;

      .content-img {
        width: 100%;
        height: 258px;
        opacity: 0.05;
        position: absolute;
        top: -13px;
        left: 0;
        z-index: 10;
      }
    }

    .title-conten {
      width: 100%;
      height: 100%;
      font-size: 26px;
      color: #ffffff;

      .rescue-gold {
        width: 54px;
        margin-left: 30px;
        height: 54px;
        margin-right: 23px;
      }
    }

    .list-conten {
      width: 100%;
      height: auto;

      .list-title {
        width: 100%;
        height: auto;
        margin-top: 2px;

        .list-title-name {
          font-size: 22px;
          color: rgba(255, 255, 255, 0.65);
          text-align: center;
          line-height: 65px;
          border-radius: 6.46px;
          background: rgba(255, 255, 255, 0.08);
        }

        .one-level {
          width: 100px;
          height: 65px;
        }

        .tew-frame {
          flex: 1;
          height: 65px;
          margin-left: 4px;
        }
      }
    }

    .list-val-frame {
      .list-title {
        .colortext {
          color: rgba(255, 255, 255, 0.45) !important;
        }
        .single {
          background: rgba(255, 255, 255, 0.02) !important;
        }
        .pair {
          background: rgba(255, 255, 255, 0.04) !important;
        }
      }
    }
  }

  .divider-frame {
    width: 100%;
    height: auto;
    margin-top: 28px;
    .divider-div {
      width: 129px;
      height: 2px;
      background-image: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.65) 100%
      );
    }
    .divider-div-rigth {
      transform: scaleX(-1);
    }
    .divider-name {
      color: rgba(255, 255, 255, 0.85);
      font-size: 24px;
      margin-left: 13px;
      margin-right: 13px;
    }
  }
  .eventDescription-frame {
    width: 100%;
    height: auto;
    font-size: 22px;
    margin-top: 6px;
    color: rgba(255, 255, 255, 0.45);
    line-height: 50px;
    .textWrap {
      word-wrap: break-word;
      margin: 0 20px 0;
    }
  }
}
</style>
